import Vue from 'vue'
import VueRouter from 'vue-router'
import recommend from '../views/recommend.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:"/",
    redirect:"/recommend"
  },
  {
    path:"/userInfo",
    name:"userInfo",
    component:()=>import("../views/userinfo.vue"),
    beforeEnter:(to,from,next)=>{
      let login = window.localStorage.getItem("token");
      // 判断没有值
      if(!login){
        next("/login");
        
      }else{
        next()
      }

    }
  },
  {
    path:"/login",
    name:"login",
    component:()=>import("../components/base/login.vue")
  },

{
  path:"/recommend",
  name:"recommend",
  component:recommend
},

{
  path:"/rank",
  name:"rank",
  component:()=>import("../views/rank.vue")
},

{
  path:"/singer",
  name:"singer",
  component:()=>import("../views/singer.vue")
},

{
  path:"/rank/ranklist",
  name:"ranklist",
  component:()=>import("../components/rank/ranklist.vue")
},

{
  path:"/search",
  name:"search",
  component:()=>import("../views/search.vue")
},

{
  path:"/userinfo/recentlyplay",
  name:"recentlyplay",
  component:()=>import("../components/userinfo/recentlyplay.vue")
},
{
  path:"/userinfo/myfriend",
  name:"recentlyplay",
  component:()=>import("../components/userinfo/myfriend.vue")
},



{
  path:"/recommend/remMv",
  name:"remMv",
  component:()=>import("../components/recommend/remMv.vue")
},





  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})

export default router
